package com.tilas.mapper;


import com.tilas.pojo.Emp;
//import com.tilas.pojo.EmpQueryParam;
import com.tilas.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


    /**
     * 查询总记录数
     * */
//    @Select("select count(*) from emp e  left join dept d on e.dept_id=d.id;")
//    public Long count();


    /**
     *
     * */
    //@Select("select e.*,d.name deptName from emp e  left join dept d on e.dept_id=d.id " +
    //"order by e.update_time desc limit #{start},#{pageSize};")
     List<Emp> list(EmpQueryParam empQueryParam);




//     @Options(useGeneratedKeys = true,keyProperty = "id")//获取到新的主键 -- 主键返回
//     @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time)" +
//             "        value (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId}," +
//             "               #{createTime},#{updateTime});")
//    void insert(Emp emp);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);


    /**
     * 根据ID批量删除员工的基本信息
     * */
    void deleteByIds(List<Integer> ids);



   /**
    * 根据员工的ID批量删除员工的工作经历
    * */
    void deleteByEmpIds(List<Integer> empIds);



    /**
     * 根据id查询员工信息
     * */
    Emp findById(Integer id);

    /**
     * 根据id更新员工的基本信息
     * */
    void updateById(Emp emp);



    /**
     * 统计员工职位人数
     * */
    @MapKey("pos")
    List<Map<String,Object>>countEmpJobDate();


    /**
     * 统计员工性别人数
     * */
    @MapKey("name")
    List<Map<String, Object>> countEmpGenderDate();


    /**
     * 根据员工的用户名和密码查询员工信息
     * */
    @Select("select id,username,name from emp where username=#{username} and password=#{password}")
    Emp selectByUsernameAndPassword(Emp emp);
}
